package com.gitee.wsl.func.procedure.sample

import com.gitee.wsl.func.predicate.Predicate
import com.gitee.wsl.func.procedure.Procedure2


/**
 * A conditional parameterized two argument procedure that effectively filters which objects should be used
 */
class IfProcedureWith<T, P>(
    private val predicate: Predicate<in T>,
    private val procedure: Procedure2<in T, in P>
) : Procedure2<T, P> {
    override fun value(each: T, parm: P) {
        if (this.predicate.accept(each)) {
            this.procedure.value(each, parm)
        }
    }
}
